
export function isEmpty(value: any): boolean {
  if (typeof value === "string" && value.trim() === "") return true;
  if (Array.isArray(value) && value.length === 0) return true;
  if (typeof value === "object" && value !== null && Object.keys(value).length === 0) return true;
  if (typeof value === "number" && value === 0) return true;
  if (typeof value === "undefined") return true;
  if (value === null) return true;
  if (value instanceof Map && value.size === 0) return true;
  if (value instanceof Set && value.size === 0) return true;
  return false;
}

export function deepClone(obj: any): any {
  if (typeof obj!== "object" || obj === null) {
    return obj;
   }
  if (obj instanceof Map) {
    const cloneMap = new Map(); 
    for (const [key, value] of obj) {
      cloneMap.set(key, deepClone(value)); 
    } 
    return cloneMap;
  } 
  if (obj instanceof Set) {
    const cloneSet = new Set();
    for (const value of obj) {
      cloneSet.add(deepClone(value));
    } 
  }
  if (obj instanceof Date) {
    return new Date(obj); 
  }
  if (obj instanceof RegExp) {
    return new RegExp(obj);
  }
  if (obj instanceof Function) {
    return obj; 
  }
  if (Array.isArray(obj)) {
    const cloneArr = [];
    for (const value of obj) {
      cloneArr.push(deepClone(value));
    }
    return cloneArr; // 添加缺失的 return
  }
  // 添加类型声明解决索引签名错误
  const cloneObj: Record<string, any> = {}; 
  for (const key in obj) {
    if (obj.hasOwnProperty(key)) {
      cloneObj[key] = deepClone(obj[key]);
    }
  }
  return cloneObj;
}